package com.clj.fastble.scan;

import com.clj.fastble.BleManager;

import ohos.bluetooth.ble.BleScanFilter;

import java.util.List;
import java.util.UUID;

/**
 * BleScanRuleConfig
 */
public class BleScanRuleConfig {
    private List<BleScanFilter> filters = null;
    private boolean mAutoConnect = false;
    private long mScanTimeOut = BleManager.DEFAULT_SCAN_TIME;

    /**
     * isAutoConnect
     * @return boolean
     */
    public boolean isAutoConnect() {
        return mAutoConnect;
    }

    /**
     * getScanTimeOut
     * @return long
     */
    public long getScanTimeOut() {
        return mScanTimeOut;
    }

    /**
     * getFilters
     * @return List
     */
    public List<BleScanFilter> getFilters() {
        return filters;
    }

    /**
     * Builder
     */
    public static class Builder {
        private List<BleScanFilter> filters = null;
        private boolean mAutoConnect = false;
        private long mTimeOut = BleManager.DEFAULT_SCAN_TIME;

        /**
         * 设置自动连接
         * @param autoConnect autoConnect
         * @return Builder
         */
        public Builder setAutoConnect(boolean autoConnect) {
            this.mAutoConnect = autoConnect;
            return this;
        }

        /**
         * 扫描超时时间
         * @param timeOut timeOut
         * @return Builder
         */
        public Builder setScanTimeOut(long timeOut) {
            this.mTimeOut = timeOut;
            return this;
        }

        /**
         * setFilters
         * @param filters filters
         * @return Builder
         */
        public Builder setFilters(List<BleScanFilter> filters) {
            this.filters = filters;
            return this;
        }

        void applyConfig(BleScanRuleConfig config) {
            config.filters = this.filters;
            config.mAutoConnect = this.mAutoConnect;
            config.mScanTimeOut = this.mTimeOut;
        }

        /**
         * build
         * @return BleScanRuleConfig
         */
        public BleScanRuleConfig build() {
            BleScanRuleConfig config = new BleScanRuleConfig();
            applyConfig(config);
            return config;
        }
    }
}
